/**
 * 功能描述 散客团信息导航条
 */
define(function (require, exports, module) {
	var Subnav = require("subnav");
	var aw = require("ajaxwrapper");
	var enmu = require("enums");
	
	var subnavEvents = require("../handler/subnavEvents");
	
    var instance = {
        initComponent: function (params, widget) {
            var subnav = new Subnav({
            	parentNode : ".J-subnav",
            	model : {
        			title : "入住体验登记",
        			items:[{
						id:"search",
						type: "search",
						placeholder: "联系人/联系电话",
						handler: function(str){
							aw.ajax({
								url: "api/nonmemgroupreserve/search*",
								data: {
									s: str,
									properties:"nonMemberGroup.contactName," +
											"nonMemberGroup.contactPhone",
									"nonMemberGroup.signUpType" : "Experience",
			            			fetchProperties : "*,nonMemberGroup.*,nonMemberGroup.servicePoint.name," +
	            					"nonMemberGroup.servicePoint.pkServicePoint," +
	            					"nonMemberGroup.operator.pkUser," +
	            					"nonMemberGroup.signUps.version," +
	            					"signUpRooms.roomType.*," +
	            					"signUpRooms.count"
								},
								dataType:"json",
								success: function(data){
									widget.get("grid").setData(data);
								}
							});
						}
					},{
        				id : "status",
        				type : "buttongroup",
        				tip : "状态",
        				items : [{
							key:"",
							value:"全部"
						},{
							key:"Initial",
							value:"初始",
						},{
							key:"Effective",
							value:"有效"
						},{
							key:"CheckIn",
							value:"入住"
						},{
							key:"CheckOut",
							value:"退住"
						}],
        				handler: function(key,element){
        					widget.get("grid").refresh();
        				}
        			},{
						id : "operateDate",
						type : "daterange",
						ranges : {
					        "本年": [moment().startOf("year"), moment().endOf("days")],
					        "本月": [moment().startOf("month"), moment().endOf("month")]
						},
						tip : "登记日期",
						handler : function(time){
							 widget.get("grid").refresh();
						}
					},{
        				id:"add",
        				type:"button",
        				text:"新增",
        				handler:function(){
        					$(".J-grid-head-formel").show();
        					widget.get("form").reset();
        					widget.get("pergrid").setData([]);
        					widget.show([".J-form",".J-pergrid"]).hide([".J-grid"]);
							widget.get("subnav").hide(["add", "status","search", "operateDate"]).show(["save", "return"]);
        				}
        			},{
        				id : "save",
						type : "button",
						text : "保存",						
						show : false,
						handler:function(){
							subnavEvents.saveAction(widget);
						}
        			},{
        				id : "return",
						type : "button",
						text : "返回",						
						show : false,
						handler:function(){
							widget.get("form").reset();
							widget.get("pergrid").setData([]);
							widget.show([".J-grid"]).hide([".J-form",".J-pergrid"]);
							widget.get("subnav").hide(["save", "return"]).show(["search","add","status", "operateDate"]);
						}
        			}]
        		}
            })
        	widget.set("subnav", subnav);
        }
    };
    module.exports = instance;
});
